package com.sh.redis.controller;

import java.util.Arrays;

public class FindZhongXinshu {

    public static void main(String[] args) {
        int[] a = new int[]{1,2,3,4,5,1,2,3,4};
        System.out.println(find(a));
    }

    private static int find(int[] a) {
        if (a ==null || a.length<=0){
            return 0;
        }
        int sum = Arrays.stream(a).sum();
        int temp = 0;
        for(int i = 0;i<a.length;i++){
            if(temp+temp + a[i] == sum){
                return i;
            }
            temp+=a[i];
        }
        return 0;
    }

}
